import React from "react";
import "../css/InputBox.css"
import eventEmitter from "../event"
class InputBox extends React.Component{
    constructor(prop){
        super(prop)
        this.state = {

        }
    }

    render(){
        return(
            <div className="input">
                <input type="text" ref="input" />
                <button onClick={()=>{
                    let value = this.refs.input.value;
                    if(value.length===0){
                        return alert("输入内容不能为空")
                    }
                    var date=new Date();
                    var datestr=`${date.getFullYear()}年${date.getMonth()+1}月${date.getDay()}日${date.getHours()}时${date.getMinutes()}分${date.getSeconds()}`
                    var  message={
                        content:value,
                        data:datestr,
                    }
                    eventEmitter.emit("sendMessageTooBoard",message)
                }}>发布</button>
            </div>
        )
    }
}

export default InputBox;